package com.leemz.design.chapter5.pattern;

public class Singleton {
    private static Singleton singleton = null;
    private Singleton(){};

    public static synchronized Singleton getInstance() {
        if(null == singleton) {
            singleton = new Singleton();
        }
        return singleton;
    }

    /**
     * 单例类可以有自己的方法
     */
    public void singletonOperation() {

    }

    /**
     * 单例类可以有自己的属性，并提供get方法供外界访问
     */
    private String singletonData;

    public String getSingletonData() {
        return singletonData;
    }
}
